import { localCache } from '@/utils/cache'
import { TOKEN } from '@/utils/token'
import { BASE_URL, TIME_OUT } from './config'
import SKRequest from './request'

const skRequest = new SKRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestSucceeFn: (config) => {
      const token = localCache.getCache(TOKEN)
      if (token && config.headers) {
        config.headers.Authorization = token
      }
      return config
    }
  }
})

export default skRequest
